const apiUrl = 'https://store.qidian2018.com/index.php/';

export default {
	/**
	 * post请求
	 * @url 请求地址
	 * @param 请求参数
	 * @success 成功回调
	 * @url 失败回调
	 */
	post(url, param, success = null, error = null) {
		uni.request({
			url: apiUrl + url,
			data: ({
				...param,
				key: getApp().globalData.key || '',
				 
			}),
			method: 'POST',
			header: {
				"Content-Type": "application/x-www-form-urlencoded",
			},
			success: (res) => {
				typeof success == 'function' ? success(res.data) : "";
			},
			error: (res) => {
				if (typeof error == 'function') {
					error(res)
				} else {
					uni.showToast({
						title: '请求超时~',
						icon: 'none'
					});
				}
			}
		});
	},
}
